﻿/// ---------------------------------------------
///
/// ---------------------------------------------

///---------------------------
///2012.4.30 汪定新添加
///身份证号码验证
function CheckIDCard(idcard) {
    var Errors = new Array(
                 "0",
                 "身份证号码位数不对!",
                 "身份证号码出生日期超出范围或含有非法字符!",
                 "身份证号码校验错误!",
                  "身份证地区非法!");
    var area = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖北", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏", 61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国外" }
    var idcard, Y, JYM;
    var S, M;
    var idcard_array = new Array();
    idcard_array = idcard.split("");
    //地区检验 
    if (area[parseInt(idcard.substr(0, 2))] == null) return Errors[4];
    //身份号码位数及格式检验 
    switch (idcard.length) {
        case 15:
            if ((parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0 || ((parseInt(idcard.substr(6, 2)) + 1900) % 100 == 0 && (parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0)) {
                ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/; //测试出生日期的合法性 
            } else {
                ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/; //测试出生日期的合法性 
            }
            if (ereg.test(idcard)) return Errors[0];
            else return Errors[2];
            break;
        case 18:
            //18位身份号码检测 
            //出生日期的合法性检查  
            //闰年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9])) 
            //平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8])) 
            if (parseInt(idcard.substr(6, 4)) % 4 == 0 || (parseInt(idcard.substr(6, 4)) % 100 == 0 && parseInt(idcard.substr(6, 4)) % 4 == 0)) {
                ereg = /^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/; //闰年出生日期的合法性正则表达式 
            } else {
                ereg = /^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/; //平年出生日期的合法性正则表达式 
            }
            if (ereg.test(idcard)) {//测试出生日期的合法性 
                //计算校验位 
                S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7
                            + (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9
                            + (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10
                            + (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5
                            + (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8
                            + (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4
                            + (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2
                            + parseInt(idcard_array[7]) * 1
                            + parseInt(idcard_array[8]) * 6
                            + parseInt(idcard_array[9]) * 3;
                Y = S % 11;
                M = "F";
                JYM = "10X98765432";
                M = JYM.substr(Y, 1); //判断校验位 
                if (M == idcard_array[17]) return Errors[0]; //检测ID的校验位 
                else return Errors[3];
            }
            else return Errors[2];
            break;
        default:
            return Errors[1];
            break;
    }
}
//验证台湾身份证
function checkTaiWanIdCard(idnum) {
    num = idnum;
    num = num.toLowerCase();
    patten = /^[a-z][12][0-9]{8}$/;
    if (patten.test(num)) {
        h = "abcdefghjklmnpqrstuvxywzio ";
        x = 10 + h.indexOf(num.substring(0, 1));
        chksum = (x - (x % 10)) / 10 + (x % 10) * 9;
        for (i = 1; i < 9; i++) {
            chksum += num.substring(i, i + 1) * (9 - i);
        }
        chksum = (10 - chksum % 10) % 10;
        if (chksum == num.substring(9, 10)) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}

//香港身份證信息，沒有性別信息，沒有地域信息。不過，還是有一個完整的驗證規則。
//　　身份證字號的樣式為XYabcdef(z)，其中X可以是英文數字或是空白不填，而Y一定是英文字母，z是檢核碼為0~10的數字(當z為10的時候，則以A表示)，要驗算是否為正確之身份證號碼時，第一個英文字若為空白則以58代替，若是英文字則依A=10，B=11，C=12，D=13…的順序繼續下去，第二個英文字作法亦同，然後依照以下規則算出數字後，再加上檢核碼一定會是11的倍數~
//　　例如：A123456(3)→58 10 123456
//               ＝58×9+10×8+1×7+2×6+3×5+4×4+5×3+6×2
//   　　　　＝522+80+7+12+15+16+15+12
//               ＝679
//　　679+3＝682＝11×62 是11的倍數，因此它是一個正確的身份證字號。
// 
//　　又例如：AB654321(□)　□是多少呢？
//　　　　　AB654321(□)→10 11 654321
//               ＝10×9+11×8+6×7+5×6+4×5+3×4+2×3+1×2
//   　　　　＝90+88+42+30+20+12+6+2
//               ＝290
//　　∵290÷11=26…3  
//　　∴□=3
//验证香港身份证函数
function CheckHongKongIdCard(cardNum) {
    if (!cardNum.match(/^[a-zA-Z][0-9]{6}[0-9aA]$/)) return false;
    var mul = 8, sum = (cardNum.toUpperCase().charCodeAt() - 64) * mul--;
    while (mul > 1) sum += parseInt(cardNum.substr(8 - mul, 1)) * mul--;
    var chksum = (11 - (sum % 11)).toString(16);
    if (chksum == "b") chksum = "0";
    return chksum == cardNum.substr(7, 1).toLowerCase();
}


//根据身份证号获取出生日期
function getBirthdatByIdNo(iIdNo) {
    var tmpStr = "";
    var idDate = "";
    var tmpInt = 0;
    var strReturn = "";
    var no = iIdNo.replace(/^\s+|\s+$/g, "");
    if ((no.length != 15) && (no.length != 18)) {
        return strReturn;
    }
    if (no.length == 15) {
        tmpStr = no.substring(6, 12);
        tmpStr = "19" + tmpStr;
        tmpStr = tmpStr.substring(0, 4) + "-" + tmpStr.substring(4, 6) + "-" + tmpStr.substring(6)
        return tmpStr;
    }
    else {
        tmpStr = iIdNo.substring(6, 14);
        tmpStr = tmpStr.substring(0, 4) + "-" + tmpStr.substring(4, 6) + "-" + tmpStr.substring(6)
        return tmpStr;
    }
}
//根据身份证获取性别
function getSexByIdNo(iIdNo) {
    var tmpStr = "";
    var idDate = "";
    var tmpInt = 0;
    var strReturn = "";
    var no = iIdNo.replace(/^\s+|\s+$/g, ""); ;
    if ((no.length != 15) && (no.length != 18)) {
        return strReturn;
    }
    if (no.length == 15) {
        if (parseInt(no.charAt(14) / 2) * 2 != no.charAt(14)) {
            return "男";
        }
        else {
            return "女";
        }
    }
    else {
        if (parseInt(no.charAt(16) / 2) * 2 != no.charAt(16)) {
            return "男";
        }
        else {
            return "女";
        }
    }
}

//根据出生日期获取年龄
function getAgeByBirthday(birthdayValue) {
    var dt1 = new Date(birthdayValue.replace("-", "/"));
    var dt2 = new Date();
    var age = dt2.getFullYear() - dt1.getFullYear();
    var m = dt2.getMonth() - dt1.getMonth();
    if (m < 0)
        age--;
    return age;
}

var fnAddEduHistory = function () {
}

var fnChekcIDCard = function (idcard) {
    $.get("", function (data, status) { })
}

function setEmployeeType() {
    //根据入职日期和试用期限判断员工类型,试用期还是正式
    var qixianText = $("#ProbationPeriod").find("option:selected").text();
    if (qixianText == "无") { //无试用期直接为正式员工
        instance[0].EmployeeType = "D924C147-1A23-4FBE-A958-2F58FD9377D7";
    } else {
        var JoinDate = $("#JoinDate").val(); //入职日期
        var time = new Date(Date.parse(JoinDate.replace(/-/g, "/")));
        time.setMonth(parseInt(time.getMonth()) + parseInt(qixianText.substr(0, 1)));
        var now = new Date();
        y = now.getFullYear();
        m = now.getMonth() + 1;
        d = now.getDate();
        m = m < 10 ? "0" + m : m;
        d = d < 10 ? "0" + d : d;
        var myDate = y + "-" + m + "-" + d;
        var yy = time.getFullYear()
        var mm = time.getMonth() + 1;
        var dd = time.getDate();
        mm = mm < 10 ? "0" + mm : mm;
        dd = dd < 10 ? "0" + dd : dd;
        var tempDate = yy + "-" + mm + "-" + dd;
        if (tempDate < myDate) { //试用期过 正式员工
            instance[0].EmployeeType = "D924C147-1A23-4FBE-A958-2F58FD9377D7";
        }
        else {//试用期内
            instance[0].EmployeeType = "8D7C895F-1DAD-4C72-A299-1EC9C9D13BC3";
        }
    }
    //
}

if (typeof ($) != "undefined") {
    $(document).ready(function () {
        $("#IDCardNO").change(function () { //输入身份证后,自动显示出生日期
            var cardNo = $("#IDCardNO").val();
            if (cardNo.length >= 15) {
                var str = getBirthdatByIdNo(cardNo);
                if (str != "") {
                    $("#BirthDate").val(str);
                    $("#age").val(getAgeByBirthday(str)); //年龄
                }
                var sex = getSexByIdNo(cardNo);
                if (sex != "") {
                    $("#Gender").attr("text", sex); //性别
                }
            }
        });
        $("#ProbationPeriod").change(function () {//试用期限和员工类型设定
            var shiyongQi = $("#ProbationPeriod").val();
            instance[0].ProbationPeriod = shiyongQi;
            setEmployeeType();
        });
        $("#JoinDate").mouseleave(function () { //
            if ($("#JoinDate").val() == "") return;
            setEmployeeType();
        });
        var deptName = getPar(decodeURI(location.href), "deptName");
        var empType = getPar(decodeURI(location.href), "type"); //员工所属类型 1.在职，2.不在职，3.离职,4.离退休,5 预审核
        $("#txtDepartmentID").val(deptName); //获取部门名称
        if (getPar(location.href, "id") == "") { //新增
            var deptId = getPar(location.href, "deptId");
            $("#DepartmentID").val(deptId); //获取部门ID
            GetPostions(deptId); //获取部门岗位信息
            instance[0].ID = Guid.NewGuid().ToString();
            parent.EmployeeID = instance[0].ID;
            instance[0].DepartmentID = deptId;
            if (getPar1("id") == "") {
                instance[0].EmployeeStatus = empType;
            }
            if (empType == "1" || empType == "5") {
                //在职管理时工号自动获取，不在职，离职和离退休工号自动输入
                GetSequenceNum(deptId); //获取工号
                //$("#EmployeeCode").attr("readonly", "readonly");
            }

            //民族以汉族为默认项
            $("#Nationality").val("汉族");
            //最高学历默认为本科
            $("#TopDegree").val("BenKe");
            //试用期限默认2个月
            $("#ProbationPeriod").val("7D43BF0D-6942-4997-B19F-2079D86ACF1F".toLocaleLowerCase());
            $("#PositionLevel").attr("value", ""); //职等
            $("#BloodType").attr("value", ""); //血型
            $("#ResumeSource").attr("value", ""); //招聘来源
            //增加劳动合同链接
            $("#divHTML").prepend("<table><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='#' onclick='parent.addContract();'>新增劳动合同</a></td></tr></table>");
        }
        else {   //修改
            if (getPar1("action") != "audit") {
                $("#BaseSalaryInfo").hide();
            }
            var postName = getPar(decodeURI(location.href), "postName"); //岗位名称
            //GetDeptIDByPostName(postName); //获取部门ID
            var deptId = instance[0].DepartmentID; //$("#DepartmentID").val();
            $("#DepartmentID").val(deptId); //获取部门ID
            GetPostions(deptId); //获取部门岗位信息 
            if ($("#BirthDate").val() <= "1900-01-01 ") {
                $("#BirthDate").val("");
            }
            if ($("#BirthDate").val() != "") $("#age").val(getAgeByBirthday($("#BirthDate").val())); //获取年龄
            $("#ProbationPeriod").attr("value", instance[0].ProbationPeriod); //试用期限
            if ($("#EmployeeCode").val() != "") { //当工号为空时才可修改,不为空不能修改
                //获取提报人employeeId
                YAHOO.util.Connect.asyncRequest('POST', "../EHR/GetCurrentUser.aspx", {
                    success: function (res) {
                        try {
                            var str = res.responseText;
                            if (str != "-1") {
                                var token = str.split('_');
                                var empCode = token[3];
                                if (empCode != "ZB02835" && empCode != "ZB01304" && empCode != "ZB09257" && empCode != "ZB01498" && empCode!='ZB03151') {
				   
                                    $("#EmployeeCode").attr("readonly", "readonly"); //工号不允许修改
                                    $("#form1").SetControlReadOnly();
                                    $("#PhoneNo").removeAttr("disabled"); //
                                    $("#HouseholdRegistration").removeAttr("disabled");
                                    $("#PersonnelArchivesArea").removeAttr("disabled");
                                    $("#Residence").removeAttr("disabled");
  $("#UrgencyContacRelation").removeAttr("disabled");
  $("#UrgencyContactPhoneNO").removeAttr("disabled");
  $("#MaritalStatus").removeAttr("disabled");
  $("#EName").removeAttr("disabled");
  $("#BaseSalary").removeAttr("disabled");
  $("#PositiveBaseSalary").removeAttr("disabled");
  $("#coffNum").removeAttr("disabled");
                                }
                            }
                        }
                        catch (e) {
                        }
                        finally {
                        }
                    },
                    failure: function (error) {
                        alert("数据错误：" + error.statusText);
                    }
                }, null);
                //$("#EmployeeCode").attr("readonly", "readonly"); //工号不允许修改
            }
            $("#TopDegree").val(instance[0].TopDegree); //学历
            $("#PositionLevel").attr("value", instance[0].PositionLevel); //职等
            $("#Nationality").attr("value", instance[0].Nationality); //民族
            $("#MaritalStatus").attr("value", instance[0].MaritalStatus); //婚姻
            $("#BloodType").attr("value", instance[0].BloodType); //血型
            $("#ResumeSource").attr("value", instance[0].ResumeSource); //招聘来源
            if ($("#JoinJobDate").val() <= "1900-01-01 ") {
                $("#JoinJobDate").val("");
            }
            $("#Gender").attr("value", instance[0].Gender); //性别
        }
        //        $("select").each(function () {
        //            var optionId = $(this).attr(id);
        //            $(this).find("option").each(function () {
        //                if ($(this).val() == "") {
        //                    $(this).remove();
        //                }
        //            });
        //        });

        if (getPar1("id") == "") {
            //debugger
            $("#PostID").change(function () { //岗位
                PostIDChanged();
            });
        }

        $("#BaseSalary").change(function () {
            if (LowerestSalary == 0) {
                $("#coffNum").val(1);
                return;
            }
            if (parseFloat($("#BaseSalary").val()) == parseFloat(LowerestSalary)) {
                $("#coffNum").val(1);
                return;
            }
            if (parseFloat($("#BaseSalary").val()) > parseFloat(LowerestSalary))+800
            {
                $("#coffNum").val(0.5);
                return;
            }
            if (parseFloat($("#BaseSalary").val()) > parseFloat(LowerestSalary)) {
                $("#coffNum").val(0.75);
                return;
            }
        });
    });
}

var ValueChanged = function () { //部门发生变化后
    var deptId = $("#DepartmentID").val(); 
    GetPostions(deptId); //获取该部门下所有岗位
    instance[0].DepartmentID = deptId; //调整后部门ID
}


var LowerestSalary = 0;
var PostIDChanged = function () { //部门发生变化后
    // debugger
    var url = encodeURI("../Extend/AjaxData/DataTableJsonList.aspx?entity=V_salPostCityLowerestSalary&condition=PostID='" + $("#PostID").val() + "'");
    $.get(url, function (d, s) {
        try {
            var list = eval("(" + d + ")");
            if (list.total > 0) {
                var v = list.rows[0].BaseSalary;
                LowerestSalary = v;
                $("#BaseSalary").val(v);
                $("#BaseSalaryHou").val(v);
                $("#PositiveBaseSalary").val(v);
                $("#coffNum").val(1);
                return;
            }
            else {
                LowerestSalary = 0;
            }
        } catch (err) {
            LowerestSalary = 0;
        }
    });
}


///------------------------------------
///
///
///------------------------------------
var fnGetPersonSalary = function () { //获取薪资信息
    var url = encodeURI("AjaxData/DataTableJsonList.aspx?r="+Math.random()+"&entity=V_salBaseSalary&condition=EmployeeID='" + instance[0].ID + "'");
    $.get(url, function (d, s) {
        try {
            //alert(d);
            var list = eval("(" + d + ")");
            if (list.total > 0) {
                //list.rows[0].BaseSalary;
                $("#BaseSalary").val(list.rows[0].BaseSalary);
                //$("#BaseSalaryHou").val(list.rows[0].BaseSalaryHou);
                $("#PositiveBaseSalary").val(list.rows[0].PositiveBaseSalary);
		        $("#coffNum").val(list.rows[0].CommissionCoff);
            }
        } catch (err) {
            //alert(err);
        }
    });
}







    //获取部门名称
    function GetDeptNameByID(deptID) {
        var url = "../Extend/AjaxData/jsonlist.aspx?entity=DatDepartment&condition=DeptID='" + deptID + "'";
        $.get(url, function (d, s) {
            var list = eval("(" + d + ")");
            if (list.total == 0) {
                $("#tishixinxi").text("该部门无岗位信息，请先维护部门岗位信息！");
            }
            else {
                for (var o in list.rows) {
                    var t = list.rows[o].DeptName;
                    if (typeof (t) != "undefined") {
                        $("#DeptName").val(t);
                    }
                }
            }
        });
    }

    //获取部门下的岗位
    function GetPostions(deptID) {
        $("#PostID").find('option').remove();
        $("#tishixinxi").text("");
        var url = "../Extend/AjaxData/jsonlist.aspx?entity=DatPost&condition=DeptID='" + deptID + "'";
        $.get(url, function (d, s) {
            var list = eval("(" + d + ")");
            if (list.total == 0) {
                $("#tishixinxi").text("该部门无岗位信息，请先维护部门岗位信息！");
                return;
            }
            else {
                for (var o in list.rows) {
                    var v = list.rows[o].PostID;
                    var t = list.rows[o].PostName;
                    if (typeof (t) != "undefined") {
                        $("#PostID").append("<option value='" + v + "' title='" + t + "'>" + t + "</option>");
                    }
                }
                if (getPar(location.href, "id") != "") { //修改时
                    $("#PostID").attr("value", instance[0].PostID); //岗位
                }
            }
            //岗位最低工资
            try{
            PostIDChanged();
            }catch(err){};
        });
    }

    //通过岗位名称获取部门ID
    function GetDeptIDByPostName(PostName) {
        var url = encodeURI("../Extend/AjaxData/jsonlist.aspx?entity=DatPost&condition=PostName='" + PostName + "'");
        $.get(url, function (d, s) {
            var list = eval("(" + d + ")");
            if (list.total == 0) {
                $("#tishixinxi").text("部门ID获取失败！");
            }
            else {
                for (var o in list.rows) {
                    var v = list.rows[o].DeptID;
                    if (typeof (v) != "undefined") {
                        $("#DepartmentID").val(v); //获取部门ID
                        break;
                    }
                }
            }
        });
    }

    //获取工号
    function GetSequenceNum(deptId) {
        YAHOO.util.Connect.asyncRequest('POST', "../EHR/GetSequenceNum.aspx?deptId=" + deptId, {
            success: function (res) {
                try {
                    var str = res.responseText;
                    if (str == "-1") {
                        $("#tishixinxi").text("工号分配失败，原因为该部门工号未分配，请先进行部门工号分配！");
                    }
                    else {
                        if (str.substring(0, 1) == "e")//后台程序出现异常
                        {
                            $("#tishixinxi").text("获取工号失败：\r\n" + str);
                        }
                        else {
                            $("#EmployeeCode").val(str);
                        }
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
            }
        }, null);
    }

    var fnCheckData = function () {
        try {
	    //debugger
            if ($("#EmployeeCode").val() == "") {
                return "员工工号不能为空！";
            }
            if ($("#CName").val() == "") {
                return "请输入员工姓名！";
            }
            if ($("#IDCardNO").val() == "") {
                return "请输入身份证号码！";
            }
            if ($("#txtDepartmentID").val() == "") {
                return "部门不能为空！";
            }
            if ($("#PostID").find("option:selected").text() == "") {
                return "岗位不能为空！";
            }
            if ($("#JoinDate").val() == "") {
                return "入职日期不能为空！";
            }
            if ($("#PhoneNo").val() == "") {
                return "联系电话不能为空！";
            }
            if (getPar1("id") == "" || getPar1("action") == "audit") {
                if (Trim($("#BaseSalary").val()) == "") {
                    return "试用薪资不能为空！";

                }
	        //debugger
                if(!IsRate(Trim($("#BaseSalary").val())))
                {
                     return "试用薪资必须为数值，不能含特珠字符，字母，及中文！";
                }
                if (Trim($("#PositiveBaseSalary").val()) == "") {
                    return "转正薪资不能为空，不确定请填'待定'!";
                }
            }
            //身份证号码验证
            var idCard = $("#IDCardNO").val();
            var checkInfo = CheckIDCard(idCard);
            if (checkInfo != "0")//验证不通过
            {
                var flag = checkTaiWanIdCard(idCard);
                if (!flag) {
                    flag = CheckHongKongIdCard(idCard);
                    if (!flag) return "身份证号码输入有误!"; //"身份证号码输入有误，请输入15位或18位有效身份证号码!";
                }
            }
            //邮箱验证
            var email = $("#Email").val();
            if (email != "") {
                var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
                flag = pattern.test(email);
                if (!flag) {
                    return "Email格式类似为:name@domain.com,请检查！";
                }
            }
            parent.SaveFlag = true;
            return "";
        } catch (e)
     { }
    }

    // 绑定右键
    $(document).ready(function () {
        if (getPar1("action") == "audit") {
            $("#divHTML").setInputReadOnly(true);
            fnGetPersonSalary();
            $("body").contextMenu({
                menu: 'myMenu'
            },
					function (action, el, pos) {
					    if (action == "audit") { //审核
					        fnAudit();
					    }
					    if (action == "exite") { //退出
					    }
					});
        }
       
    });

    //
    var fnAudit = function () {
        //if (fnCheckData() != "") {
        //    alert(fnCheckData());
        //    return;
        //}
        Save();
        if (confirm("确认是否审核？")) {
            $.get("/Extend/AjaxData/DataAction.aspx?entity=employee&action=audit&id=" + instance[0].ID,
                    function (d) {
                        if (d == "1") {
                            alert("己审核，人员档案会进入在职状态!");
                            GetPostData(_CurDeptID);
                        }
                    });
        }

        //alert("");
    }

    var CallBack = function () {
        //debugger
        if (!(getPar1("id") == "" || getPar1("action") == "audit")) {
            return;
        } else {
            var url = "../EHR/hrSalaryAjax.aspx?flag=savebasesalary&empId=" + instance[0].ID + "&salary=" + $("#BaseSalary").val() + "&salaryHou=" + $("#BaseSalary").val() + "&PositiveBaseSalary=" + $("#PositiveBaseSalary").val() + "&edate=" + instance[0].JoinDate + "&coff=" + $("#coffNum").val() + "&r=" + Math.random();
            YAHOO.util.Connect.asyncRequest('POST', encodeURI(url), {
                success: function (res) {
                    try {
                        var str = res.responseText;
                        if (str == "0") {
                            //alert("数据保存成功！");
                        }
                        else {
                            //alert("数据保存失败！");
                        }
                    }
                    catch (e) {
                    }
                    finally {
                    }
                },
                failure: function (error) {
                    alert("数据错误：" + error.statusText);
                }
            }, null);
        }
    }

function LTrim(str) { //去掉字符串 的头空格
    var i; for (i = 0; i < str.length; i++)
        if (str.charAt(i) != " " && str.charAt(i) != " ") { break; }
    str = str.substring(i, str.length);
    return str;
}
function RTrim(str) { var i; for (i = str.length - 1; i >= 0; i--) { if (str.charAt(i) != " " && str.charAt(i) != " ") break; } str = str.substring(0, i + 1); return str; }
function Trim(str) { return LTrim(RTrim(str)); }